<?php
include("../ParseContent.php");
include("../InsertData.php");
class ParseContentWindows  implements ParseContent{
	public function parseAllContent($urls,$regs,$cid){
		$insert = new InsertDate();
		foreach ($urls as $url) {
			$url = BASEURLWINDOWS.$url;
			$obj = ParseContentWindows::parseContent($url, $regs);
			//把类型名换成类型id，parsecontent中采集类别名称是鸡肋。
			$obj['type']=$cid;
			$insert->insert($obj);
		}
	}
	
	public function  parseContent($url,$regs){
		echo "采集内容==>>".$url;
		sleep(10);
		//默认是采集的 
		$isCollect = true;
		//如果url打不开就不进行采集了
		$fp = @fopen($url,"r") or $isCollect = false;
		if(isCollect){
			$fcontent = file_get_contents($url);
			$games = iconv("utf-8", "utf-8//IGNORE", $fcontent);
			//游戏名称
			preg_match_all("/{$regs['name']}/", $games, $namm);
			$name=$namm[1][0];
			
			//日期
			//preg_match_all("/日期:<\/strong>(.*?)<\/li>/", $ab[0], $datt);
			preg_match_all("/{$regs['date']}/", $games, $datt);
			$datee=$datt[1][0];
			$date = date("Y-m-d H:m",strtotime($datee)); 
			
			//大小
			//preg_match_all("/大小:<\/strong>(.*?)<\/li>/", $ab[0], $sezz);
			preg_match_all("/{$regs['size']}/", $games, $sezz);
			$size=$sezz[1][0];
			
			//详细介绍
			preg_match_all("/{$regs['introduce']}/",$games,$introducc);
			$introduce = strip_tags($introducc[1][0]);
			
			//开始地址
			$startURL=$url;
			
			//flash地址
			$flash = $url;
			
			//图片地址
			preg_match_all("/{$regs['img']}/",$games,$imgg);
			$image = strip_tags($imgg[1][0]);
			
			$result = array("name" =>$name,"type"=>$type,"date"=>$date,"size"=>$size,"introduce"=>$introduce,"flash"=>$flash,"image"=>$image);
			return $result;
		}
	}
}